package com.qingcheng.controller;

import com.qingcheng.entity.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice//标记为异常处理类
public class BaseExceptionHandler {

    @ExceptionHandler(Exception.class)//指定发生异常的类型进入该方法
    @ResponseBody
    public Result error(Exception e){

        e.printStackTrace();

        System.out.println("调用了qingcheng_common_web中的异常处理error");

        return new Result(1,e.getMessage());

    }

}
